<template>
	<view class="pad20">
			<view class="pl20 pr20" style="padding: 0rpx;">				
				<!-- 地图 -->
				<view class="page-section page-section-gap">
					<map style="width: 100%; height: 100vh;" :longitude="longitude" :latitude="latitude" :markers="covers"
						@markertap='selmark'>
					</map>
				</view>
			</view> 
	</view>
</template>

<script>
	export default {
		data() {
			return {
				wx: "https://app.mzmzb.com",
				adressInfo: '', //收货地址
				addressUserName:'',//收货人
				warnMessage:'错误',//消息内容
				warnType:'warn',//消息类型  success/warn/info/error
				warnTime:1000,//消息提醒延长时间
				id:0, // 使用 marker点击事件 需要填写id
				title: 'map',
				covers: [
					{
					latitude: '',
					longitude: '',
					// iconPath: 'http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/map1.png'
					label:{},
				}
				],
				addressId:'',//收货地址id
				buyMode:1,//取药方式
				payState:null,//支付状态 (0-未支付 1-已支付 2-已派药 3-待退款)
				latitude: '',//纬度
				longitude: '',//精度
				evaluatetext:'',
				treatName:'',//就诊人
				recipeCode:'',//就诊卡号
				treatSex:'',//就诊人性别
				treatAge:'',//就诊人年龄
				treatWeight:'',//就诊人体重
				medDocOrdsId:'',//开单序号
				recipeId:'',//ID号
				doctorDept:'',//科室
				entrustDoc:'',//诊断结果
				totalFee:'',//药品价格
				doctorName:'',//开方医生
				auditState:'',//审方状态 -1:未审核0:审核未通过 1:审核通过
				auditName:'',//审方药师
				auditDate:'',//日期
				auditRemark:'',//审核备注
				userRecipeDrug:[],//药品列表
				usrUserId:null,
				chinRecipeType:0,
				recipeInfo: undefined,
				allOfficina: []
			};
		},
		onLoad() {
			uni.getLocation({
				success: (res) => {
					this.longitude = res.longitude
					this.latitude = res.latitude
					this.initData(res.longitude,res.latitude);
				}
			});
		},
		onShow() {
			
		},
		methods: {
			selmark(evt){
				let medOfficinaInfoId = evt.detail
				if(medOfficinaInfoId){
					// console.log(medOfficinaInfoId)
					let selOfficina = this.allOfficina.filter(item=>item.medOfficinaInfoId == medOfficinaInfoId.markerId)
					// console.log(selOfficina)
					let medOfficinaInfoName = selOfficina[0].name
					let pages = getCurrentPages();
					let prevPage = pages[pages.length-2]
					prevPage.$vm.selYfId = medOfficinaInfoId.markerId
					prevPage.$vm.selYfMc = medOfficinaInfoName
					prevPage.$vm.istj = false
					prevPage.$vm.iszd = true
					uni.navigateBack({
						delta:1
					})
				}
			},
			initData(aa,bb){
				this.covers = []
				uni.request({
					url: this.wx + '/application-usrapp/applyRecipe/queryOfficinaList.tz',
					method: 'GET',
					data: {
						longitude: aa,
						latitude: bb
					},
					header: {
						'content-type': 'application/json'
					},
					success: (res) => {
						if (res.data.success = true) {
							console.log('initData',res.data.result)
							let list = res.data.result
							this.allOfficina = list
							list.forEach(item=>{
								this.covers.push(
									{
										id: item.medOfficinaInfoId,
										latitude: item.latitude,
										longitude: item.longitude,
										// iconPath: 'http://tuozhen1.oss-cn-beijing.aliyuncs.com/ueditor/upload/weixin/images/map1.png'
										label:{
											content: item.name,
											textAlign:'right'
										},
									}
								)
							})
							// wx.getLocation(Object object)
						}
					}
				})
			}
		}
	};
</script>

<style lang="less">
	page {
		.bsdh{
			font-size: 31rpx;
			background-color: #F73809;
			color: #F7F7F7;
			width: 30%;
			padding-top: 10rpx;
			padding-bottom: 10rpx;
			margin-left: 90px;
			margin-top: 10px;

		}
		background: #74a6fd;

		image {
			width: 260rpx;
			margin: 0 auto;
			display: block;
		}
		.red{
			color: red;
		}
		.big {
			line-height: 44rpx;
		}

		.big::before {
			content: '';
			position: absolute;
			width: 44rpx;
			height: 44rpx;
			background: #74A6FD;
			border-radius: 50%;
			left: -25rpx;
			top: 0;
		}

		.big::after {
			content: '';
			position: absolute;
			width: 44rpx;
			height: 44rpx;
			background: #74A6FD;
			border-radius: 50%;
			right: -25rpx;
			top: 0;
		}

		.medicine>view {
			background: #efefef;
		}
		
		.check{
			width: 28rpx;
			height: 28rpx;
			margin-right: 15rpx;
		}
		.btns{
			width: 660rpx;
			height: 100rpx;
			line-height: 100rpx;
			border-radius: 10rpx;
			background: #74a6fd;
		}
		.evaluate{
			display: block;
			width: 170rpx;
			line-height: 60rpx;
			border: 1rpx solid #efefef;
			border-radius: 10rpx;
			
		}
		.star{
			width: 52rpx;
			height: 50rpx;
			margin:25rpx 20rpx;
		}
		.evaluatetext{
			width: 505rpx;
			height: 205rpx;
			border: 1rpx solid #EFEFEF;
			border-radius: 15rpx;
			margin: 0 auto;
		}
		.map{
			width: 626rpx;
			height: 400rpx;
		}
	}
</style>
